package com.example.demo.mapper;

import com.example.demo.pojo.vo.UserProfileVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FollowMapper {
    @Select("select id from follow where user_id = #{userId} and followed_id = #{followedId}")
    Long selectIdByIds(Long userId, Long followedId);

    @Insert("insert into follow (user_id, followed_id, create_time, update_time) values (#{userId}, #{followedId}, now(), now())")
    boolean addFollow(Long userId, Long followedId);

    @Select("select user.id, name, picture from follow join user on follow.followed_id=user.id where user_id = #{userId} order by follow.id desc")
    List<UserProfileVO> selectFollowedUserProfileByUserId(Long userId);

    @Delete("delete from follow where user_id = #{userId} and followed_id = #{followedId}")
    boolean deleteFollow(Long userId, Long followedId);
}
